package com.changgou.search.controller;

import com.changgou.search.service.SkuService;
import entity.Result;
import entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author zhengjd
 * @date 2020/5/9 21:27
 */
@RestController
@RequestMapping("/search")
@CrossOrigin
public class SkuController {

    @Autowired
    SkuService skuService;
    /**
     * 导入sku数据到es中
     */
    @GetMapping("/import")
    public Result search(){
        skuService.importSku();
        return new Result(true, StatusCode.OK,"sku数据导入ES成功");
    }

    /**
     * 搜索
     * @param searchMap
     * @return
     */
    @GetMapping
    public Map search(@RequestParam(required = false) Map searchMap){
        return skuService.search(searchMap);
    }

    /**
     * 搜索
     * @param searchMap
     * @return
     */
    /*@PostMapping
    public Map search(@RequestBody(required = false) Map searchMap){
        return skuService.search(searchMap);
    }*/
}
